package com.gs.auth.controller;

import com.gs.auth.po.TbUser;
import com.gs.auth.vo.UserVo;
import com.gs.auth.service.UserService;
import com.gs.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping("/feign/selectUser")
    public TbUser selectUser(String userAccount, String password){
        TbUser tbUser = userService.selectUser(userAccount,password);
        return tbUser;
    }

    @RequestMapping("/getInfo")
    public AjaxResult getInfo(){
        TbUser tbUser = userService.getUserInfo(1L);
        AjaxResult ajaxResult=AjaxResult.success();
        ajaxResult.put("user",tbUser);
        ajaxResult.put("roles","admin");
        ajaxResult.put("permissions","*:*:*");
        return ajaxResult;
    }

    @RequestMapping("/user/queryCode")
    public AjaxResult queryCode(String phone){
        userService.queryCode(phone);
        return AjaxResult.success("已发送验证码");
    }

    @RequestMapping("/user/register")
    public AjaxResult register(@RequestBody UserVo userVo){
        userService.register(userVo);
        return AjaxResult.success("注册成功");
    }



}
